#!/bin/bash
PREFIX=/usr/local
if [[ -d $1 ]]; then
  PREFIX=$1
elif [[ -n $1 ]]; then
  echo "Invalid install directory $1"
  exit 1
fi
PREFIX=$(cd $PREFIX; pwd)
echo "Install fastlogin into $PREFIX"
cd $(dirname $0)
ROOT=$(pwd)
mkdir -p $PREFIX
mkdir -p $PREFIX/bin
rm -f $PREFIX/bin/x
mkdir -p $PREFIX/fastlogin
cp $ROOT/x $ROOT/ssh-expect $ROOT/*.py $ROOT/*.properties $PREFIX/fastlogin
ln -s $PREFIX/fastlogin/x $PREFIX/bin/x
chmod +x $PREFIX/fastlogin/*
